package com.msb.filterandlistrer.interceptor;

import org.springframework.lang.Nullable;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/** 拦截器处理demo1
 * @author LiuShanshan
 * @version V1.0
 * @Description
 */
public class InterceptorDemo1 implements HandlerInterceptor{

    // 处理controller请求之前
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        System.out.println("拦截器，调用请求之前执行=======================");
        return false;
    }

    // 处理controller之后，生成视图之前
    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, @Nullable ModelAndView modelAndView) throws Exception {
        System.out.println("拦截器，生成视图之前执行--------------------------");
    }

    // 处理controller之后
    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, @Nullable Exception ex) throws Exception {
        System.out.println("拦截器，调用接口结束执行@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
    }
}
